﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CR.Domain.Migrations
{
    public partial class users : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AdditiveInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ProductionBatch = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AdditiveInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AnimalQuarantineCertificate",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CertificateImagePath = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AnimalQuarantineCertificate", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AuxiliaryMaterialInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ProductionBatch = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AuxiliaryMaterialInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "BreedingEnterpriseInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    FarmName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    ResponsiblePerson = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    LivestockCount = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BreedingEnterpriseInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "BreedingInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Breed = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Source = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    BreedingSite = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    EndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    BreedingDays = table.Column<int>(type: "int", nullable: false),
                    FeedBrand = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    EnvironmentDescription = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    ResponsiblePerson = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    MarketingDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BreedingInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "DeepProcessingInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    Team = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ResponsiblePerson = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DeepProcessingInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "EnterprisePhoto",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    PhotoType = table.Column<int>(type: "int", nullable: false),
                    PhotoPath = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EnterprisePhoto", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "FoodSafetyInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    SafetyImagePath = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FoodSafetyInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HealthcareInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    BreedingDays = table.Column<int>(type: "int", nullable: false),
                    HealthcareMethod = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    HealthcareProcess = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HealthcareInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PackagingMaterialInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ProductionBatch = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PackagingMaterialInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProcessingEnterpriseInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CompanyName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    ProductionLicense = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProcessingEnterpriseInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProductInspectionReport",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ReportImagePath = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductInspectionReport", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RawMaterialInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ProductionBatch = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RawMaterialInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RelatedData",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    DataImagePath = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RelatedData", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SlaughterEnterpriseInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    EnterpriseType = table.Column<int>(type: "int", nullable: false),
                    CompanyName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    EstablishedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CompanyAddress = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    CompanyDescription = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SlaughterEnterpriseInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SlaughterInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    BatchDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    AverageWeight = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    ArrivalTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    SlaughterTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SlaughterInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SupplierInfo",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    SupplierType = table.Column<int>(type: "int", nullable: false),
                    ImagePath = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    IsDeleted = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SupplierInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TraceabilityManagement",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TraceabilityCode = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ProductName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    ProductionBatch = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ShelfLife = table.Column<int>(type: "int", nullable: false),
                    ProductionLicenseNumber = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    ProductionCompany = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    CoverImage = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    CompletenessScore = table.Column<int>(type: "int", nullable: false),
                    IsDeleted = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TraceabilityManagement", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_TraceabilityManagement_TraceabilityCode",
                table: "TraceabilityManagement",
                column: "TraceabilityCode",
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AdditiveInfo");

            migrationBuilder.DropTable(
                name: "AnimalQuarantineCertificate");

            migrationBuilder.DropTable(
                name: "AuxiliaryMaterialInfo");

            migrationBuilder.DropTable(
                name: "BreedingEnterpriseInfo");

            migrationBuilder.DropTable(
                name: "BreedingInfo");

            migrationBuilder.DropTable(
                name: "DeepProcessingInfo");

            migrationBuilder.DropTable(
                name: "EnterprisePhoto");

            migrationBuilder.DropTable(
                name: "FoodSafetyInfo");

            migrationBuilder.DropTable(
                name: "HealthcareInfo");

            migrationBuilder.DropTable(
                name: "PackagingMaterialInfo");

            migrationBuilder.DropTable(
                name: "ProcessingEnterpriseInfo");

            migrationBuilder.DropTable(
                name: "ProductInspectionReport");

            migrationBuilder.DropTable(
                name: "RawMaterialInfo");

            migrationBuilder.DropTable(
                name: "RelatedData");

            migrationBuilder.DropTable(
                name: "SlaughterEnterpriseInfo");

            migrationBuilder.DropTable(
                name: "SlaughterInfo");

            migrationBuilder.DropTable(
                name: "SupplierInfo");

            migrationBuilder.DropTable(
                name: "TraceabilityManagement");
        }
    }
}
